﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Practices.Unity;
using ePlanet.SingleWell.Services;
using Wuqi.Webdiyer;

namespace Web.Views.SingleWellManage
{
    public partial class SingleWellListView : PageBase
    {
        [Dependency]
        public ISingleWellService m_ISingleWellService
        {
            get;
            set;
        }

        private DataTable m_DataTable = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.BindData();
            }
        }

        private void BindData()
        {
            if (this.GetData())
            {
                this.gv_SingleWellList.DataSource = this.m_DataTable;
                this.gv_SingleWellList.PageIndex = pagerdo.CurrentPageIndex;
                this.gv_SingleWellList.DataBind();
            }
        }

        protected void pagerTransfered_PageChanging(object sender, PageChangingEventArgs e)
        {
            pagerdo.CurrentPageIndex = e.NewPageIndex;
            BindData();
        }

        private bool GetData()
        {
            try
            {
                DataTable oDataTable = this.m_ISingleWellService.GetAllSingleWell();
                if (oDataTable != null && oDataTable.Rows.Count > 0)
                {
                    this.m_DataTable = oDataTable;
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }
    }
}